package org.handsomezhi.shortlink.project.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {

    @Value("${spring.rabbitmq.template.exchange}")
    private String statsSaveExchange;
    @Value("${spring.rabbitmq.template.routing-key}")
    private String directKey;
    @Value("${spring.rabbitmq.template.queueName}")
    private String queueName;

    @Bean
    public DirectExchange directExchange1() {
        return ExchangeBuilder.directExchange(statsSaveExchange).build();
    }

    @Bean
    public Queue queue1(){
        return QueueBuilder.durable(queueName).build();
    }


    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(queue1()).to(directExchange1()).with(directKey);
    }
}
